﻿@model IEnumerable<MvcCms.Store.ViewModels.OrderViewModel>
<br /> 
@foreach (var order in Model)
{    
    var orderDetails = order.OrderDetails;
    <table>
    <tr>
        <th colspan="3">
        Order Number: @order.OrderID
        </th>
    </tr>
    <tr>
        <th>
            Product
        </th>
        <th>
            Quantity
        </th>
        <th>
            UnitPrice
        </th>
    </tr>
    @foreach (var orderDetail in orderDetails)
    {
        <tr>
            <td>
        @if (orderDetail.PriceOptionID.HasValue && orderDetail.PriceOption.RequiresNotes)
        {
            @orderDetail.PriceOption.Title
        }
        else
        {
            @orderDetail.Product.Title
        }
            </td>
            <td>
                @orderDetail.Quantity
            </td>
            <td>
                @String.Format("{0:F}", orderDetail.UnitPrice)
            </td>
        </tr>
    }
    <tr>
        <td>
        Total:
        </td>
        <td></td>
        <td>
            @String.Format("{0:F}", order.Total)
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <div class="shipping-info-container">
                <fieldset>
                    <legend>Shipping Information</legend>
                    @Html.DisplayFor(x=>order)
                    @if (order.ShippingMethodRate!=null){
                        if (order.ShippingMethodRate.ShippingMethod != null)
                        {
                            <br /><strong>
                            <text>Shipping Method: </text>
                            </strong>
                            @order.ShippingMethodRate.ShippingMethod.Title.ToString()
                        }
                    }                    
                </fieldset>
            </div>
        </td>
    </tr>
    @if (!string.IsNullOrEmpty(order.OrderNotes))
    {
    <tr>
        <td colspan="3">
            <div class="orderNotes">
                @Html.Raw(order.OrderNotes)
            </div>        
        </td>
    </tr>
    }
</table>
<br />   
}
